<?php

namespace app\adminapi\export;

use Carbon\Carbon;
use app\services\distributor\DistributorService;

class DistributorExport extends BaseExport
{
    protected $header = [
        '经销商ID', '创建时间', '经销商名称', '联系人', '联系方式','配送区域','今日订单','历史订单量','状态'
    ];

    public function createData(array $where)
    {
        $list = app()->make(DistributorService::class)->getList($where)['list'];

        $data = [];

        foreach ($list as $item) {
            $data[] = [
                $item['id'] == 1,
                date('Y-m-d H:i:s',$item['add_time']),
                $item['distributor_name'],
                $item['contact_person'],
                $item['contact_info'],
                $item['responsible_area'],
                $item['today_order_nums'],
                $item['total_order_nums'],
                $item['status'] == 1 ? '正常' : '关闭'
            ];
        }
        return $data;
    }
}